package com.ctshk.rpc.order.tour.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ctshk.rpc.order.tour.code.IsDeletedCode;
import com.ctshk.rpc.order.tour.req.SeriesOrderTouristRefundDetailListReq;
import com.ctshk.rpc.order.tour.req.SeriesOrderTouristRefundDetailListTripReq;
import org.apache.ibatis.annotations.Param;

/**
 * <p>
 * 系列团游客签证记录 Provider 接口
 * </p>
 *
 * @author 谭响
 * @since 2021-01-18
 */
public class SeriesOrderTouristRefundDetailProvider {

    public String selectListBySelective(IPage<SeriesOrderTouristRefundDetailListReq> pageParam,
                                        @Param("req") SeriesOrderTouristRefundDetailListReq req) {
        StringBuilder sb = new StringBuilder();
        sb.append("select ");
        sb.append("tsotrd.id,tsoti.order_id, tsoti.schedule_id, tsotr.tourist_id, tsotr.refund_number,tsotrd.refund_amount,tsotrd.actual_refund_amount, ");
        sb.append("tsoti.cn_surname, tsoti.cn_name,tsoti.en_surname, tsoti.en_name, ");
        sb.append("tsotrd.refund_id, tsotrd.refund_status, tsotrd.refund_detail_type_id, tsotrd.refund_detail_type, ");
        sb.append(" tsotrd.refund_type_id, tsotrd.refund_type, tsotrd.refund_account, ");
        sb.append("tsotrd.refund_reason_id, tsotrd.refund_reason, tsotrd.remark, tsotrd.create_id, ");
        sb.append("tsotrd.gmt_create ");
        sb.append("FROM t_series_order_tourist_refund_detail tsotrd ");
        sb.append("LEFT JOIN t_series_order_tourist_refund tsotr ON tsotr.id = tsotrd.refund_id ");
        sb.append("LEFT JOIN t_series_order_tourist_info tsoti ON tsoti.id = tsotr.tourist_id ");
        sb.append("where 1=1 ");
        sb.append("and tsotr.order_id = #{req.orderId} ");
        sb.append("and tsotr.tourist_id = #{req.touristId} ");
        sb.append("and tsotr.is_deleted=" + IsDeletedCode.NO.getCode() + " ");
        sb.append("order by tsotrd.gmt_create desc ");
        return sb.toString();
    }

    public String selectListTripBySelective(IPage<SeriesOrderTouristRefundDetailListTripReq> pageParam,
                                        @Param("req")SeriesOrderTouristRefundDetailListTripReq req) {
        StringBuilder sb = new StringBuilder();
        sb.append("select ");
        sb.append("tsoti.order_id, tsoti.schedule_id, tsotr.tourist_id, tsotr.refund_number, ");
        sb.append("tsoti.cn_surname, tsoti.cn_name, ");
        sb.append("tsotrd.refund_id, tsotr.refund_status, tsotrd.refund_detail_type_id, tsotrd.refund_detail_type, ");
        sb.append("tsotrd.refund_amount, tsotrd.refund_type_id, tsotrd.refund_type, tsotrd.refund_account, ");
        sb.append("tsotrd.refund_reason_id, tsotrd.refund_reason, tsotrd.remark, tsotrd.create_id, ");
        sb.append("tsotrd.gmt_create ");
        sb.append("FROM t_series_order_tourist_refund_detail tsotrd ");
        sb.append("LEFT JOIN t_series_order_tourist_refund tsotr ON tsotr.id = tsotrd.refund_id ");
        sb.append("LEFT JOIN t_series_order_tourist_info tsoti ON tsoti.id = tsotr.tourist_id ");
        sb.append("where 1=1 ");
        sb.append("and tsotr.schedule_id = #{req.scheduleId} ");
        sb.append("and tsotr.is_deleted=" + IsDeletedCode.NO.getCode() + " ");
        return sb.toString();
    }

}
